/*
	Temperature.h
	Christopher Raffaele
	04.28.2008

	Temperature's class definitions
*/
#include"TemperatureDec.h" //Temperature class declarations

//show menu
void Temperature::showMenu(){
	std::cout << "\n--------------------------------\n"
		 << "\\           Temperature         \\\n"
		 << " ---------------------------------\n"
		 << " | 1 | C to F                    |\n"
		 << " ---------------------------------\n"
		 << " | 2 | F to C                    |\n"
		 << " ---------------------------------\n";
}

//prompt for choice
void Temperature::start(){
	int temp; //variable for choice

	do{ //continuously prompt until 0 is entered
		showMenu();

		std::cout << "\nConvert temperature in what direction (0 to return to main)? ";
		std::cin >> temp;

		switch (temp){
			case 0:
				break;
			case 1:
				getCelsius(); //get the degrees to be converted
				break;
			case 2:
				getFahrenheit(); //get the degrees to be converted
				break;
			default: //number other than 1 or 2
				std::cout << "\nInvalid Selection\n";
				system("pause"); //wait
		}
	}while(temp != 0);
}

//display converted degrees
void Temperature::getCelsius(){
	std::cout << "\nEnter degrees in Celsius: ";
	double degrees; //variable for degrees to be converted
	std::cin >> degrees;
	std::cout << "\n" << degrees << " degrees Celsius is " << toFahrenheit(degrees) << " degrees Fahrenheit.\n";
	system("pause"); //wait
}

//display converted degrees
void Temperature::getFahrenheit(){
	std::cout << "\nEnter degrees in Fahrenheit: ";
	double degrees; //variable for degrees to be converted
	std::cin >> degrees;
	std::cout << "\n" << degrees << " degrees Fahrenheit is " << toCelsius(degrees) << " degrees Celsius.\n";
	system("pause"); //wait
}

double Temperature::toCelsius(double fahrenTemp){
	return ((fahrenTemp - 32) * 5 / 9); //return converted degrees
}

double Temperature::toFahrenheit(double celsiusTemp){
	return (celsiusTemp * 9 / 5 + 32); //return converted degrees
}
